﻿@{ 
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "登录";
}  
  <input type="hidden" id="TenantId" name="TenantId" value="" />
    <div class="header"></div>
    <div class="loginWraper">
        <div id="loginform" class="loginBox">
            <form class="form form-horizontal" id="formLogin">
                <div class="row cl">
                    <label class="form-label col-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                    <div class="formControls col-8">
                        <input id="" name="phoneNum" type="text" placeholder="手机号" class="input-text size-L">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-3"><i class="Hui-iconfont">&#xe60e;</i></label>
                    <div class="formControls col-8">
                        <input id="" name="password" type="password" placeholder="密码" class="input-text size-L">
                    </div>
                </div>
                <div class="row cl">
                    <div class="formControls col-8 col-offset-3">
                        <input class="input-text size-L" name="VerifyCode" type="text" placeholder="验证码" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:" style="width:150px;">
                        <img src="~/Main/CreateVerifyCode" id="imgVerifyCode"> <a id="kanbuq" href="javascript:;">看不清，换一张</a>
                    </div>
                </div>
                <div class="row">
                    <div class="formControls col-8 col-offset-3">
                        <label for="online">
                            <input type="checkbox" name="online" id="online" value="">
                            使我保持登录状态
                        </label>
                    </div>
                </div>
                <div class="row">
                    <div class="formControls col-8 col-offset-3">
                        <input name="" type="button" id="btnLogin" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
                        <input name="" type="reset" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="footer">Copyright 你的公司名称 by H-ui.admin.v2.3</div>
@section FooterScript
{
<script type="text/javascript" src="~/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="~/js/H-ui.js"></script>
<script type="text/javascript">
    $(function () {
        $("#kanbuq,#imgVerifyCode").click(function () {
            $("#imgVerifyCode").attr("src","/Main/CreateVerifyCode?"+Math.random());
        });
        $("#imgVerifyCode").click();//为了避免页面刚打开的时候加载缓存中"/Main/CreateVerifyCode"
            //因此要主动点击一下，刷新验证码
        $("#btnLogin").click(function () {
            var formData = $("#formLogin").serializeArray();
            $.ajax({
                url: "/Main/Login", dataType: "json", type: "post", data: formData,
                success:function(res)
                {
                    if (res.status == "ok")
                    {
                        //alert("登录成功");
                        location.href = "/Main/Index";
                    }
                    else
                    {
                        alert("错误：" + res.errorMsg);
                        $("#imgVerifyCode").click();
                    }
                },
                error:function()
                {
                    alert("网络出错");
                }
            });
        });
    });
</script>
}
